package com.fz.mapper;

import com.fz.entity.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by webrx on 2017-09-12.
 */

public interface BookMapper {

    @Select("select * from db_book where id=#{id}")
    public Book queryById(int id);

    @Select("select * from db_book order by id desc")
    public List<Book> queryAll();
    //两种添加方式
    @Insert("insert into db_book values(null,#{name},#{price},#{bdate})")
    public int add(Book book);

    @Insert("insert into db_book values(null,#{name},#{price},#{bdate})")
    public int save(@Param("name") String name,@Param("price") double price,@Param("bdate") String bdate);

    //删除的方法
    @Delete("delete from db_book where id=#{id}")
    public int delete(int id);
}
